﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Barcode.ascx.cs" Inherits="ERP.Modules.Barcode" %>
<ext:Panel ID="PanelBarCode" runat="server" Layout="Fit" Border="False">
    <Content>
        <ext:GridPanel
            ID="grBarCode"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreBarCode"
                    runat="server"
                    OnReadData="StoreBarCode_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="ID_BarCode" GroupField="EncodeType">
                            <Fields>
                                <ext:ModelField Name="EncodeType" Type="String" />
                                <ext:ModelField Name="BarCode" Type="String" />
                                <ext:ModelField Name="GenerateLabel" Type="Boolean" />
                                <ext:ModelField Name="ImageFormat" Type="String" />
                                <ext:ModelField Name="ImagesPath" Type="String" />
                                <ext:ModelField Name="Width" Type="String" />
                                <ext:ModelField Name="Height" Type="String" />
                                <ext:ModelField Name="Alignment" Type="String" />
                                <ext:ModelField Name="Backcolor" Type="String" />
                                <ext:ModelField Name="Forecolor" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Loại mã vạch" Width="200" DataIndex="EncodeType"/>
                    <ext:Column runat="server" Text="Mã vạch" Width="200" DataIndex="BarCode"/>
                    <ext:TemplateColumn
                        runat="server"
                        Text="Hình ảnh"
                        Flex="15" 
                        DataIndex="ImagesPath" 
                        TemplateString='<img style="width:60px;height:45px;" src="{ImagesPath}" />'
                    />
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="BarCodeDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="ID_BarCode" Value="record.data.ID_BarCode" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grBarCode}, #{FormatTypeBarCode}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </TriggerClick>
                                <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreBarCode" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <ext:Window ID="Wbarcode" runat="server"
            Title="Tạo mã vạch"
            DefaultAnchor="100%"
            Width="975"
            Height="546"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Offsets"
            Maximizable="False"
            Minimizable="False"
            Border="False"
            Padding="5"
            Resizable="False">
            <Content>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSave">
                            <DirectEvents>
                                <Click OnEvent="btnSave_Click" Before="return #{FormPanelBarCode}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Tạo mã" Icon="PageWhiteAdd" ID="btnCreateBarCode">
                            <DirectEvents>
                                <Click OnEvent="btnCreateBarCode_Click" Before="return #{FormPanelBarCode}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Bỏ qua" Icon="Cancel" ID="btnCancel" MarginSpec="0 8 0 0">
                            <DirectEvents>
                                <Click OnEvent="btnCancel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Panel
                    runat="server" 
                    Layout="ColumnLayout">
                    <Items>
                        <ext:Panel
                            runat="server" 
                            Width="218"
                            Frame="True"
                            MarginSpec="0 5 0 0"
                            Height="520">
                            <Items>
                                <ext:FormPanel ID="FormPanelBarCode" 
                                    runat="server"
                                    AutoHeight="true"
                                    BodyPadding="4"
                                    Frame="true"
                                    DefaultAnchor="100%">
                                    <Items>
                                        <ext:TextField ID="lbID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                                        <ext:TextField ID="lbPath" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Loại mã vạch" Margins="8 3 0 0" />
                                        <ext:SelectBox
                                            ID="SelectcbEncodeType"
                                            runat="server"
                                            MarginSpec="8 8 8 0"
                                            AllowBlank="False"
                                            AnchorHorizontal="100%"
                                            EmptyText="Chọn loại mã vạch">
                                            <Items>
                                                <ext:ListItem Value="UPC-A" Text="UPC-A"/>
                                                <ext:ListItem Value="UPC-E" Text="UPC-E"/>
                                                <ext:ListItem Value="UPC 2 Digit Ext" Text="UPC 2 Digit Ext"/>
                                                <ext:ListItem Value="UPC 5 Digit Ext" Text="UPC 5 Digit Ext"/>
                                                <ext:ListItem Value="EAN-13" Text="EAN-13"/>
                                                <ext:ListItem Value="JAN-13" Text="JAN-13"/>
                                                <ext:ListItem Value="EAN-8" Text="EAN-8"/>
                                                <ext:ListItem Value="ITF-14" Text="ITF-14"/>
                                                <ext:ListItem Value="Interleaved 2 of 5" Text="Interleaved 2 of 5"/>
                                                <ext:ListItem Value="Standard 2 of 5" Text="Standard 2 of 5"/>
                                                <ext:ListItem Value="Codabar" Text="Codabar"/>
                                                <ext:ListItem Value="Postnet" Text="Postnet"/>
                                                <ext:ListItem Value="Bookland-ISBN" Text="Bookland-ISBN"/>
                                                <ext:ListItem Value="Code 11" Text="Code 11"/>
                                                <ext:ListItem Value="Code 39" Text="Code 39"/>
                                                <ext:ListItem Value="Code 39 Extended" Text="Code 39 Extended"/>
                                                <ext:ListItem Value="Code 93" Text="Code 93"/>
                                                <ext:ListItem Value="Code 128" Text="Code 128"/>
                                                <ext:ListItem Value="Code 128-A" Text="Code 128-A"/>
                                                <ext:ListItem Value="Code 128-B" Text="Code 128-B"/>
                                                <ext:ListItem Value="Code 128-C" Text="Code 128-C"/>
                                                <ext:ListItem Value="LOGMARS" Text="LOGMARS"/>
                                                <ext:ListItem Value="MSI" Text="MSI"/>
                                                <ext:ListItem Value="Telepen" Text="Telepen"/>
                                                <ext:ListItem Value="FIM (Facing Identification Mark)" Text="FIM (Facing Identification Mark)"/>
                                                <ext:ListItem Value="Pharmacode" Text="Pharmacode"/>
                                            </Items>
                                        </ext:SelectBox>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã vạch" />
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtData" runat="server" AllowBlank="False" Text="038000356216" Width="165" MaskRe="[\d\-]" BlankText="Vui lòng nhập vào mã vạch theo quy định" Margins="8 3 0 0" />
                                                <ext:Button runat="server" Text="" Icon="Help" ID="btnTutorial" ToolTip="Click vào để xem hướng dẩn" Margins="8 3 0 0">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnTutorial_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Hiễn thị mã vạch" />
                                        <ext:Checkbox runat="server" ID="chkGenerateLabel" Checked="True"/>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Định dạng tệp ảnh" Margins="8 3 0 0" />
                                        <ext:SelectBox
                                            ID="SelectImageFormat"
                                            runat="server"
                                            MarginSpec="8 8 8 0"
                                            AllowBlank="False"
                                            AnchorHorizontal="100%"
                                            EmptyText="Chọn loại giá">
                                            <Items>
                                                <ext:ListItem Value="GIF" Text="GIF"/>
                                                <ext:ListItem Value="JPEG" Text="JPEG"/>
                                                <ext:ListItem Value="PNG" Text="PNG"/>
                                                <ext:ListItem Value="TIFF" Text="TIFF"/>
                                                <ext:ListItem Value="BMP" Text="BMP"/>
                                            </Items>
                                        </ext:SelectBox>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Hiễn thị" Margins="8 3 0 0" />
                                        <ext:Radio ID="rbAlignLeft" 
                                            runat="server" 
                                            Name="alignment"
                                            InputValue="left"
                                            BoxLabel="Left" />
                                        <ext:Radio ID="rbAlignCenter" 
                                            runat="server" 
                                            Name="alignment"
                                            InputValue="center" 
                                            BoxLabel="Center" 
                                            Checked="True" />
                                        <ext:Radio ID="rbAlignRight" 
                                            runat="server" 
                                            Name="alignment"
                                            InputValue="right" 
                                            BoxLabel="Right"/>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Màu nổi" Margins="8 3 0 0" />
                                        <ext:FieldContainer ID="FieldContainer2"
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtForeColor" runat="server" Text="000000" ReadOnly="True" AllowBlank="False" Width="165" Margins="8 3 0 0" />
                                                <ext:Button runat="server" Text="" Icon="Color" ID="btnForeColor" ToolTip="Click vào để chọn màu" Margins="8 3 0 0">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnForeColor_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Màu nền" Margins="8 3 0 0" />
                                        <ext:FieldContainer ID="FieldContainer3"
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtBackColor" runat="server" Text="FFFFFF" ReadOnly="True" AllowBlank="False" Width="165" Margins="8 3 0 0" />
                                                <ext:Button runat="server" Text="" Icon="Color" ID="btnBackgroundColor" ToolTip="Click vào để chọn màu" Margins="8 3 0 0">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnBackgroundColor_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Chiều dài" Margins="8 3 0 0" />
                                        <ext:NumberField runat="server" MinValue="0" ID="txtWidth" AllowBlank="False" Text="150" AnchorHorizontal="100%"/>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Chiều cao" Margins="8 3 0 0" />
                                        <ext:NumberField ID="txtHeight" runat="server" MinValue="0" AllowBlank="False" Text="50" AnchorHorizontal="100%"/>
                                    </Items>
                                </ext:FormPanel>
                            </Items>
                        </ext:Panel>
                        <ext:Panel
                            runat="server" 
                            Width="736"
                            Frame="True"
                            Layout="Fit" 
                            BBarCode="False"
                            Height="485">
                            <Items>
                                <ext:Image runat="server" ID="BarcodeImage" />
                            </Items>
                        </ext:Panel>
                    </Items>
                </ext:Panel>
            </Content>
        </ext:Window>
        <ext:Window ID="Wcolor" runat="server"
            Title="Mã màu"
            Width="157"
            Height="124"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Display"
            Border="False"
            Padding="5"
            Resizable="False">
            <Content>
                <ext:ColorPicker ID="ColorPickerBg" runat="server">
                <DirectEvents>
                    <Select OnEvent="AjaxColor_Changed" />
                </DirectEvents>
        </ext:ColorPicker>
            </Content>
        </ext:Window>
        <ext:Window ID="WColorFColor" runat="server"
            Title="Mã màu"
            Width="157"
            Height="124"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Display"
            Border="False"
            Padding="5"
            Resizable="False">
            <Content>
                <ext:ColorPicker ID="ColorFcolor" runat="server">
                <DirectEvents>
                    <Select OnEvent="ColorFcolor_Changed" />
                </DirectEvents>
        </ext:ColorPicker>
            </Content>
        </ext:Window>
        <ext:Window ID="WviewImg" runat="server"
            Title="Xem ảnh"
            Width="157"
            Height="124"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Display"
            Border="False"
            Padding="5"
            Resizable="False">
            <Content>
                    <ext:Image runat="server" ID="ImgView" />
            </Content>
        </ext:Window>
        </Content>
</ext:Panel>